<?php
	ob_start();
	session_start();

	function __autoload($class_name) {
		include './'.$class_name . '.php';
	}
	
	$result = array();
	$orderId=$_GET['orderId'];	
	$paymentMode = $_GET['payment'];
	$status = true;	
	$dbConfig = new DBConfigNew(); 
	$conn = $dbConfig->getConnection();
	$tranStatus = 'N';
	$orderId = stripslashes($orderId);
	$orderId = mysql_real_escape_string($orderId);
	$paymentMode = stripslashes($paymentMode);
	$paymentMode = mysql_real_escape_string($paymentMode);
	$query = null;
	
	if ($conn->connect_errno) {
		$status = false;		
	}
	$query = "CALL hambaaco_merchandize.order_u('".$orderId."','".$paymentMode."',@cd_status_tran);";
	
	if($status && !$conn->multi_query($query)) {
		$status = false;
	}
	
	if ($status){
		$statusOut=$conn->query( 'select @cd_status_tran');
		while($row = $statusOut->fetch_object()){
			$tranStatus = $row->{'@cd_status_tran'};	
		}
	}	
	$dbConfig -> closeConnection();
	$results['tranStatus'] = $tranStatus;
	if($status) {
		$results['#success'] = true;		
	}else{
		$results['#success'] = false;
	}
	
	$_SESSION['cart']=null;
	
	echo json_encode($results);
	ob_end_flush();
?>